The present invention relates computers, and, in particular, accessing unaligned data from a memory device.
Memory lines are typically divided into cache line boundaries. In the example illustrated in FIG. 1, the cache lines are sub-divided into 8-byte boundaries. If a memory address corresponds to a boundary line, the memory address is considered an xe2x80x9caligned accessxe2x80x9d. If a memory address does not corresponds to a boundary line it is considered an unaligned access, and can typically take 2.5 times longer to access.
The number of unaligned access is typically high in computer applications. As a result, the memory latency associated with the unaligned accesses creates a bottleneck effect that limits the performance of image/video processing and other applications.
The present invention provides a method and apparatus for accessing data from a memory. The method includes masking off a portion of a first memory address, and accessing a first unit of data corresponding to the first memory address. In addition, the method includes adding a predetermined offset to the first memory address to generate a second memory address, and accessing a second unit of data corresponding to the second memory address. Thereafter, a section of the first unit of data is shifted off, and a separate section from the second unit of data is shifted off. Next, the first unit of data and the second unit of data are joined.